package com.mvd.app.upload;

import android.annotation.TargetApi;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;

import com.iceteck.silicompressorr.SiliCompressor;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Progress;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.mvd.app.api.ApiConfig;
import com.mvd.app.application.UploadEvent;
import com.mvd.app.commons.PDALogUtils;
import com.mvd.app.commons.UtilsLog;
import com.mvd.app.model.VideoUploadModel;
import com.zolad.videoslimmer.VideoSlimmer;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.File;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @ProjectName: PDA_38900_guizhou
 * @Package: com.mvd.app.upload
 * @ClassName: MyUploadService
 * @Description: java类作用描述
 * @Author: liuxj
 * @CreateDate: 2020-11-02 15:42
 * @UpdateUser: 更新者
 * @UpdateDate: 2020-11-02 15:42
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class MyUploadService extends Service implements ApiConfig {
    private String outputDir =
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
    private long startTime, endTime;


    //    private Compressor mCompressor;
    private String currentOutputVideoPath = "";//压缩后的视频地址

    private String videoTime = "";//获取视频时长
    private int videoWidth = 0;//获取视频的宽度
    private int videoHeight = 0;//获取视频的高度
    private int videoGotation = 0;//获取视频的角度
    private Bitmap mBitMap;
    private Double videoLength = 0.00;//视频时长 s
    private Handler handler = new Handler();
    MyRunnable myRunnable = new MyRunnable();//定义MyRunnable的对象；
    VideoUploadModel model = null;
//    private CustomProgressDialog mProcessingDialog;

//    private String mVideoPath = "";//原视频地址

    //    public static final String PATH =
//            Environment.getExternalStorageDirectory().getAbsolutePath() + "/apeng/";
    class MyRunnable implements Runnable {//内部类实现Runnable接口；

        @Override
        public void run() {//还是在Runnable重写的run()方法中更新界面；
//            text.setText("使用Handler更新了界面");
//            videoCompress(model.getSize(), model.getZp(), model);
//            video_VideoProcessor(model.getSize(), model.getZp(), model);
//            videoCompress_low(model.getSize(), model.getZp(), model);
//            videoCompress_medium(model.getSize(), model.getZp(), model);
            siliCompressor(model.getSize(), model.getZp(), model);
        }
    }

    void siliCompressor(String videoUriString, String videoPath, final VideoUploadModel model) {
        String foder = Environment.getExternalStorageDirectory() + "/compress/";
        Log.e("tag", "压缩视频的文件夹为：" + foder);
        String logStr = "视频压缩====siliCompressor===";
        PDALogUtils.createLogFile(20, logStr.getBytes());
        File file = new File(foder);
        if (!file.exists()) {
            file.mkdirs();
        }
        new VideoCompressAsyncTask(this).execute(videoUriString, file.getPath());
//        StringfilePath= SiliCompressor.with(BaseApplication.getSelf()).compressVideo(videoPath, destinationDirectory，outWidth，outHeight，bitrate);参数传入原视频videoPath和压缩后destinationDirectory存放的文件夹，返回压缩后图片绝对路径。横屏视频的outWidth宽度   outHeight高度   bitrate比特率（码率）越高数据大  体积越大一般450000
    }

    class VideoCompressAsyncTask extends AsyncTask<String, String, String> {

        Context mContext;

        public VideoCompressAsyncTask(Context context) {
            mContext = context;
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            String logStr = "视频压缩====VideoCompressAsyncTask===";
            PDALogUtils.createLogFile(20, logStr.getBytes());
        }

        @Override
        protected String doInBackground(String... paths) {
            String filePath = null;
            try {
                MediaMetadataRetriever retriever = new MediaMetadataRetriever();
                retriever.setDataSource(paths[0]);
                String width = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
                String height = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
                double widths = Integer.parseInt(width) * 0.9;
                double heights = Integer.parseInt(height) * 0.9;
                int videoWidth = new Double(widths).intValue();
                int videoHeight = new Double(heights).intValue();
                filePath = SiliCompressor.with(mContext).compressVideo(paths[0], paths[1], videoHeight, videoWidth, 1200000);
                Log.e("tag", "压缩完成了老哥，要开始上传啦~~");
                Log.e("tag", "压缩后的路径为===" + filePath);
                if (filePath != null) {
                    String logStr = "视频压缩完成，即将开始上传======="+filePath;
                    PDALogUtils.createLogFile(20, logStr.getBytes());
                    getDataUploadVideo2(model, filePath, "");
                } else {
                    String logStr = "视频压缩失败=======";
                    PDALogUtils.createLogFile(20, logStr.getBytes());
                    getDataUploadVideo2(model, model.getSize(), "");
                }
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
            return filePath;

        }

        //得到压缩好的路径
        @Override
        protected void onPostExecute(String compressedFilePath) {
            super.onPostExecute(compressedFilePath);

        }
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        UtilsLog.e("MyService.onBind------------");
        return null;
    }

    @Override
    public void onCreate() {
        UtilsLog.e("MyService.onCreate------------");
        EventBus.getDefault().register(this);
        super.onCreate();
    }

    @Subscribe(threadMode = ThreadMode.ASYNC)
    public void getUploadEventBus(UploadEvent event) {
        UtilsLog.e("MyUploadService===" + event.getMessage());
        UtilsLog.e("MyUploadService===" + event.getPath());
//        filePath = event.getMessage();
//        filePath2 = event.getPath();
//        if (event != null) {
////            getDataUploadPhoto(new File(event.getMessage()));
//            new Thread(new Runnable() {
//                @Override
//                public void run() {
//                    Message msg = new Message();
////                    msg.obj = event.getMessage();
//                    msg.arg1 = 1;
//                    handler_main.sendMessage(msg);
//                }
//            }).start();
//        }
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        UtilsLog.e("MyService.onStartCommand------------");
        if (intent != null) {
//            String data=intent.getStringExtra("service_data");
//            UserAccountModel model= (UserAccountModel) intent.getSerializableExtra("service_user_model");
//            UtilsLog.e("MyService.onStartCommand--------data----"+data);
//            UtilsLog.e("MyService.onStartCommand--------UserAccountModel----"+model.toString());
            VideoUploadModel model = (VideoUploadModel) intent.getSerializableExtra("service_model");
            UtilsLog.e("MyService.onStartCommand--------VideoUploadModel----" + model.toString());

//            new Thread() {
//
//                @Override
//                public void run() {
//                    handler.post(myRunnable);//调用Handler.post方法；
//                }
//            }.start();
//            videoCompress(model.getSize(), model.getZp(), model);
            getDataUploadVideo3(model);

//            getDataUploadVideo2(model, model.getSize(), "");
        }
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        UtilsLog.e("MyService.onDestroy------------");
        super.onDestroy();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        UtilsLog.e("MyService.onUnbind------------");
        EventBus.getDefault().unregister(this);
        return super.onUnbind(intent);
    }

    void videoCompress(String videoUriString, String videoPath, final VideoUploadModel model) {
        VideoSlimmer.convertVideo(videoUriString, videoPath, 480, 800, 200 * 360 * 30, new VideoSlimmer.ProgressListener() {
            @Override
            public void onStart() {
            }

            @Override
            public void onFinish(boolean result) {
                UtilsLog.e("videoCompress---视频路径=onFinish=" + result);
//                //convert finish,result(true is success,false is fail)
//                getDataUploadVideo(model);
            }

            @Override
            public void onProgress(float percent) {
                UtilsLog.e("videoCompress---视频路径=onProgress=" + percent);
            }
        });
    }

        //上传视频
    private void getDataUploadVideo3(final VideoUploadModel carsInforModel) {
        UtilsLog.e("MyUploadService---上传视频---url==" + carsInforModel.getPath());
        UtilsLog.e("carsInforModel=getDataUploadVideo3=" + carsInforModel.getCarNO());
        String logStr = "\n" + "MyUploadService-getDataUploadVideo3--上传录像视频----" +
                "\n" + "URL::" + carsInforModel.getPath() + "\n" ;
        PDALogUtils.createLogFile(20, logStr.getBytes());
        OkGo.<String>post(carsInforModel.getPath())
                //次数
                .params("Times", carsInforModel.getTimes())
                //PlatformSN
                .params("PlatformSN", carsInforModel.getPlatformSN())
                .params("VideoType", carsInforModel.getVideoType())
                .params("ItemCode", carsInforModel.getItemCode())
                //车牌号码，两个拼起来的
                .params("CarNO", carsInforModel.getCarNO())
                //号牌类型
                .params("PlateType", carsInforModel.getPlateType())
                //外检车道，检测线代号
                .params("Line", carsInforModel.getLine())
                //车辆识别代码
                .params("VIN", carsInforModel.getVIN())
                //照片
//                .params("zp", new File(carsInforModel.getZp()))
                .params("zp", new File(carsInforModel.getSize()))
                //开始时间
                .params("StartTime", carsInforModel.getStartTime())
                //结束时间
                .params("EndTime", carsInforModel.getEndTime())
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "上传中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
//                        CommonUtils.hideLoadingDialog(instances);
                        String result = response.body();
                        UtilsLog.e("MyUploadService---上传视频-result==" + result);
                        String logStr = "\n" + "MyUploadService--getDataUploadVideo3-外检上传视频--请求成功" +
                                "\n" + "URL::" + carsInforModel.getPath() + "\n" + "result:" + response.body() + "\n";
                        PDALogUtils.createLogFile(20, logStr.getBytes());
                        if (!TextUtils.isEmpty(result) && !"[[]]".equals(result) && !"[{}]".equals(result)
                                && !"[]".equals(result)) {
                            String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\",
                                    "");
                            UtilsLog.e("MyUploadService---上传视频-newResult==" + newResult);
                            if ("ok".equalsIgnoreCase(newResult)) {
                                UtilsLog.e("MyUploadService---上传视频-成功==");
                                carsInforModel.setStatement("1");
                                carsInforModel.save();
                            }
                        } else {
                            UtilsLog.e("MyUploadService---上传视频-result==" + "没有数据");
                        }

                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
//                        UpVideo_ok = false;
                        UtilsLog.e("MyUploadService---上传视频-onError==" + response.body());
                        UtilsLog.e("MyUploadService---上传视频-onError==" + response.getException());
                        String logStr = "\n" + "MyUploadService-getDataUploadVideo3--上传录像视频-onError-失败" +
                                "\n" + "URL::" + carsInforModel.getPath() + "\n" + "result:" + response.body() + "\n" +
                                response.getException() + "\n" + response.message() + "\n";
                        PDALogUtils.createLogFile(20, logStr.getBytes());
//                        CommonUtils.hideLoadingDialog(instances);
//                        Toast.makeText(instances, "上传录像失败，请重试", Toast.LENGTH_LONG).show();
                    }
                });
    }
    private Locale getLocale() {
        Configuration config = getResources().getConfiguration();
        Locale sysLocale = null;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            sysLocale = getSystemLocale(config);
        } else {
            sysLocale = getSystemLocaleLegacy(config);
        }

        return sysLocale;
    }

    @SuppressWarnings("deprecation")
    public static Locale getSystemLocaleLegacy(Configuration config) {
        return config.locale;
    }

    @TargetApi(Build.VERSION_CODES.N)
    public static Locale getSystemLocale(Configuration config) {
        return config.getLocales().get(0);
    }

    int upload_times = 0;//上传视频的次数

    //上传视频 is:是否压缩  true  是   false 否
    private void getDataUploadVideo(final VideoUploadModel carsInforModel, boolean is, String currentOutputVideoPath) {
        String video_url_path = "";
        if (!TextUtils.isEmpty(currentOutputVideoPath)) {
            video_url_path = currentOutputVideoPath;
        } else {
            if (is) {
                video_url_path = carsInforModel.getZp();
            } else {
                video_url_path = carsInforModel.getSize();
            }
        }
        UtilsLog.e("MyUploadService---getDataUploadVideo==start==" + new SimpleDateFormat("HH:mm:ss", getLocale()).format(new Date()));
        UtilsLog.e("MyUploadService---上传视频---currentOutputVideoPath==" + currentOutputVideoPath);
        UtilsLog.e("MyUploadService---上传视频---carsInforModel==" + carsInforModel.toString());
        UtilsLog.e("MyUploadService---上传视频---url==" + carsInforModel.getPath());
        String logStrqw = "\n" + "MyUploadService---外检上传视频--getDataUploadVideo--" +
                "\n" + "currentOutputVideoPath::" + currentOutputVideoPath + "\n"
                + "carsInforModel:" + carsInforModel.toString() + "\n"
                + "url:" + carsInforModel.getPath() + "\n";
        PDALogUtils.createLogFile(20, logStrqw.getBytes());
        OkGo.<String>post(carsInforModel.getPath())
//                .isMultipart(true)
                //次数
                .params("Times", carsInforModel.getTimes())
                //PlatformSN
                .params("PlatformSN", carsInforModel.getPlatformSN())
                .params("VideoType", carsInforModel.getVideoType())
                .params("ItemCode", carsInforModel.getItemCode())
                //车牌号码，两个拼起来的
                .params("CarNO", carsInforModel.getCarNO())
                //号牌类型
                .params("PlateType", carsInforModel.getPlateType())
                //外检车道，检测线代号
                .params("Line", carsInforModel.getLine())
                //车辆识别代码
                .params("VIN", carsInforModel.getVIN())
                //照片
                .params("zp", new File(video_url_path))
                //开始时间
                .params("StartTime", carsInforModel.getStartTime())
                //结束时间
                .params("EndTime", carsInforModel.getEndTime())
                .execute(new StringCallback() {

                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "上传中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
//                        CommonUtils.hideLoadingDialog(instances);
                        UtilsLog.e("MyUploadService---getDataUploadVideo==onSuccess==" + new SimpleDateFormat("HH:mm:ss", getLocale()).format(new Date()));
                        String result = response.body();
                        UtilsLog.e("MyUploadService---上传视频-result==" + result);
                        String logStr = "\n" + "MyUploadService---外检上传视频--请求成功" +
                                "\n" + "URL::" + carsInforModel.getPath() + "\n" + "result:" + response.body() + "\n";
                        PDALogUtils.createLogFile(20, logStr.getBytes());
                        if (!TextUtils.isEmpty(result) && !"[[]]".equals(result) && !"[{}]".equals(result)
                                && !"[]".equals(result)) {
                            String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\",
                                    "");
                            UtilsLog.e("MyUploadService---上传视频-newResult==" + newResult);
                            if ("ok".equalsIgnoreCase(newResult)) {
                                UtilsLog.e("MyUploadService---上传视频-成功==");
                                carsInforModel.setStatement("1");
                                carsInforModel.save();
                            }
                        } else {
                            UtilsLog.e("MyUploadService---上传视频-result==" + "没有数据");
                        }
                        upload_times = 0;
                    }

                    @Override
                    public void uploadProgress(Progress progress) {
                        super.uploadProgress(progress);
                        String str = "MyUploadService---totalSize:" + progress.totalSize +
                                "currentSize:" + progress.currentSize +
                                "date:" + progress.date +
                                "fraction:" + String.valueOf(progress.fraction) +
                                "exception:" + progress.exception;
                        UtilsLog.e("上传视频==uploadProgress====" + str);
                        UtilsLog.e("上传视频==uploadProgress====" + (progress.fraction * 100) + "%");
                        String logStr = "\n" + "上传视频==uploadProgress====" +
                                "\n" + "uploadProgress::" + str + "\n"
                                + "Progress::" + progress.toString();
                        PDALogUtils.createLogFile(20, logStr.getBytes());
                        carsInforModel.setProgress(progress.fraction);
                        carsInforModel.save();
//                        EventBus.getDefault().post(carsInforModel);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("MyUploadService---getDataUploadVideo==onError==" + new SimpleDateFormat("HH:mm:ss", getLocale()).format(new Date()));
//                        UpVideo_ok = false;
                        UtilsLog.e("MyUploadService---上传视频-onError==" + response.body());
                        UtilsLog.e("MyUploadService---上传视频-onError==" + response.getException());
                        String logStr = "\n" + "MyUploadService---上传录像视频-onError-失败" +
                                "\n" + "URL::" + carsInforModel.getPath() + "\n" + "result:" + response.body() + "\n" +
                                response.getException() + "\n" + response.message() + "\n";
                        PDALogUtils.createLogFile(20, logStr.getBytes());
                        upload_times++;
                        if (upload_times < 3) {
                            String logStr12 = "\n" + "MyUploadService---上传录像视频-" +
                                    upload_times + "次上传==" + "\n";
                            PDALogUtils.createLogFile(20, logStr12.getBytes());
                            getDataUploadVideo(carsInforModel, true, currentOutputVideoPath);
                        }
//                        CommonUtils.hideLoadingDialog(instances);
//                        Toast.makeText(instances, "上传录像失败，请重试", Toast.LENGTH_LONG).show();
                    }
                });
    }

    //上传视频 is:是否压缩  true  是   false 否
    private void getDataUploadVideo2(final VideoUploadModel carsInforModel, String filePath, String currentOutputVideoPath) {
        String video_url_path = "";
        if (!TextUtils.isEmpty(currentOutputVideoPath)) {
            video_url_path = currentOutputVideoPath;
        } else {
            video_url_path = filePath;
        }
        UtilsLog.e("MyUploadService---getDataUploadVideo==start==" + new SimpleDateFormat("HH:mm:ss", getLocale()).format(new Date()));
        UtilsLog.e("MyUploadService---上传视频---currentOutputVideoPath==" + currentOutputVideoPath);
        UtilsLog.e("MyUploadService---上传视频---carsInforModel==" + carsInforModel.toString());
        UtilsLog.e("MyUploadService---上传视频---url==" + carsInforModel.getPath());
        String logStrqw = "\n" + "MyUploadService---外检上传视频--getDataUploadVideo2--" +
                "\n" + "currentOutputVideoPath::" + currentOutputVideoPath + "\n"
                + "carsInforModel:" + carsInforModel.toString() + "\n"
                + "url:" + carsInforModel.getPath() + "\n";
        PDALogUtils.createLogFile(20, logStrqw.getBytes());
        OkGo.<String>post(carsInforModel.getPath())
//                .isMultipart(true)
                //次数
                .params("Times", carsInforModel.getTimes())
                //PlatformSN
                .params("PlatformSN", carsInforModel.getPlatformSN())
                .params("VideoType", carsInforModel.getVideoType())
                .params("ItemCode", carsInforModel.getItemCode())
                //车牌号码，两个拼起来的
                .params("CarNO", carsInforModel.getCarNO())
                //号牌类型
                .params("PlateType", carsInforModel.getPlateType())
                //外检车道，检测线代号
                .params("Line", carsInforModel.getLine())
                //车辆识别代码
                .params("VIN", carsInforModel.getVIN())
                //照片
//                .params("zp", new File(video_url_path))
                .params("zp", new File(carsInforModel.getSize()))
                //开始时间
                .params("StartTime", carsInforModel.getStartTime())
                //结束时间
                .params("EndTime", carsInforModel.getEndTime())
                .execute(new StringCallback() {

                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "上传中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
//                        CommonUtils.hideLoadingDialog(instances);
                        UtilsLog.e("MyUploadService---getDataUploadVideo==onSuccess==" + new SimpleDateFormat("HH:mm:ss", getLocale()).format(new Date()));
                        String result = response.body();
                        UtilsLog.e("MyUploadService---上传视频-result==" + result);
                        String logStr = "\n" + "MyUploadService---外检上传视频--请求成功" +
                                "\n" + "URL::" + carsInforModel.getPath() + "\n" + "result:" + response.body() + "\n";
                        PDALogUtils.createLogFile(20, logStr.getBytes());
                        if (!TextUtils.isEmpty(result) && !"[[]]".equals(result) && !"[{}]".equals(result)
                                && !"[]".equals(result)) {
                            String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\",
                                    "");
                            UtilsLog.e("MyUploadService---上传视频-newResult==" + newResult);
                            if ("ok".equalsIgnoreCase(newResult)) {
                                UtilsLog.e("MyUploadService---上传视频-成功==");
                                carsInforModel.setStatement("1");
                                carsInforModel.save();
                            }
                        } else {
                            UtilsLog.e("MyUploadService---上传视频-result==" + "没有数据");
                        }
                        upload_times = 0;
                    }

                    @Override
                    public void uploadProgress(Progress progress) {
                        super.uploadProgress(progress);
                        String str = "MyUploadService---totalSize:" + progress.totalSize +
                                "currentSize:" + progress.currentSize +
                                "date:" + progress.date +
                                "fraction:" + String.valueOf(progress.fraction) +
                                "exception:" + progress.exception;
                        UtilsLog.e("上传视频==uploadProgress====" + str);
                        UtilsLog.e("上传视频==uploadProgress====" + (progress.fraction * 100) + "%");
                        String logStr = "\n" + "上传视频==uploadProgress====" +
                                "\n" + "uploadProgress::" + str + "\n"
                                + "Progress::" + progress.toString();
                        PDALogUtils.createLogFile(20, logStr.getBytes());
                        carsInforModel.setProgress(progress.fraction);
                        carsInforModel.save();
//                        EventBus.getDefault().post(carsInforModel);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("MyUploadService---getDataUploadVideo==onError==" + new SimpleDateFormat("HH:mm:ss", getLocale()).format(new Date()));
//                        UpVideo_ok = false;
                        UtilsLog.e("MyUploadService---上传视频-onError==" + response.body());
                        UtilsLog.e("MyUploadService---上传视频-onError==" + response.getException());
                        String logStr = "\n" + "MyUploadService---上传录像视频-onError-失败" +
                                "\n" + "URL::" + carsInforModel.getPath() + "\n" + "result:" + response.body() + "\n" +
                                response.getException() + "\n" + response.message() + "\n";
                        PDALogUtils.createLogFile(20, logStr.getBytes());
                        upload_times++;
                        if (upload_times < 3) {
                            String logStr12 = "\n" + "MyUploadService---上传录像视频-" +
                                    upload_times + "次上传==" + "\n";
                            PDALogUtils.createLogFile(20, logStr12.getBytes());
                            getDataUploadVideo(carsInforModel, true, currentOutputVideoPath);
                        }
//                        CommonUtils.hideLoadingDialog(instances);
//                        Toast.makeText(instances, "上传录像失败，请重试", Toast.LENGTH_LONG).show();
                    }
                });
    }
}
